﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Web;
using System.Xml.XPath;
using Com.FastSearch.SharePoint.WebControls.ESPSearchWebParts.UI;

namespace Com.FastSearch.SharePoint.Interfaces
{
    /// <summary>
    /// Defines a full search result, which has document summaries (<see cref="Items"/>),
    /// navigators, and meta-information (like number of hits, 
    /// </summary>
    public interface IESPSearchResult
    {

        /// <summary>
        /// The number of hits/documents this query resulted in.
        /// </summary>
        int DocCount { get; }

        /// <summary>
        /// An estimated value indicating the maximum possible ranking value for the
        /// current search. No rank values should be greater than this value. The first
        /// hit may have a lower rankvalue than maxrank.  The maximum rank value returned
        /// using this interface represents a theoretical maximum rank for this query.
        /// Note however that this value will not be normalized across different queries.
        /// Hence, a rank value only represents the relative rank for a result within
        /// a query.
        /// </summary>
        long MaxRank { get; }

        /// <summary>
        /// Time used to do the search. (From the time the qrserver receives it until the results are written.)
        /// </summary>
        string TimeToSearch { get;}

        /// <summary>
        /// A list iterator for the document summaries in this query result.
        /// The document summaries are instances of <see cref="IESPDocumentSummary"/>.
        /// </summary>
        List<IESPDocumentSummary> Items { get; }

        /// <summary>
        /// The names of the navigators in this query result, in the same order
        /// as their named navigator in <see cref="Navigators"/>.
        /// </summary>
        string[] NavigatorNames { get; }

        /// <summary>
        /// The navigators in this query result, in the same order as their names
        /// in <see cref="NavigatorNames"/>.
        /// </summary>
        IESPNavigator[] Navigators { get; }

        /// <summary>
        /// XML representing the N first search results.
        /// </summary>
        IXPathNavigable XmlResult { get; }

        /// <summary>
        /// Returns a named navigator from the query result. The name must be one of the
        /// values in <see cref="NavigatorNames"/>.
        /// </summary>
        /// <param name="navigatorName">The name of the navigator to get</param>
        /// <returns>The specified navigator</returns>
        IESPNavigator GetNavigator(string navigatorName);

        /// <summary>
        /// Returns XML containing the search statistics for the specified interval.
        /// Gives information about the time the search took, how many documents were
        /// found, and which interval is currently being shown (using the parameters).
        /// </summary>
        /// <param name="offset">Offset of the search</param>
        /// <param name="hitsperpage">Number of hits per page</param>
        /// <returns>search statistics as XML</returns>
        IXPathNavigable GetXmlSearchStatistics(int offset, int hitsperpage);

        /// <summary>
        /// Returns XML containing any query suggestions or modifications.
        /// </summary>
        /// <returns>spelling suggestions or modifications as XML</returns>
        IXPathNavigable GetXmlDidYouMean(HttpRequest request, ESPSearchGroupEnum espSearchGroup, IESPSearchSettings searchSettings);

        /// <summary>
        /// Returns XML containing any featured content entries.
        /// </summary>
        /// <returns>Featured content entries as XML</returns>
        IXPathNavigable GetXmlFeaturedContent(HttpRequest request, ESPSearchGroupEnum espSearchGroup, IESPSearchSettings searchSettings);

        /// <summary>
        /// Will be used to mark the result object as in debug mode.
        /// Can for example be used to render the reults differently.
        /// </summary>
        bool DebugMode { get; set; }
    }
}
